<?php
class BuyPasswordModel extends Db {
	
	private $_buy_password = 'd_buy_password';
	
	public function addUser($params) {
		return $this->add ( $this->_buy_password, $params );
	}
	
	public function savedUser($v, $uid) {
		return $this->update ( $this->_buy_password, $v, array ('uid' => $uid ) );
	}
	
	public function getUserByUid($uid) {
		return $this->getOne ( $this->_buy_password, array ('uid' => $uid ) );
	}
	
	public function savePasswordByUid($password, $uid) {
		return $this->update ( $this->_buy_password, array ('password' => $password, 'status' => 1 ), array ('uid' => $uid ) );
	}
	
	public function addFaildNum($uid) {
		$sql = "UPDATE $this->_buy_password SET num=num+1 WHERE uid=$uid";
		return $this->exec ( $sql );
	}
	
	public function setNumByUid($num, $uid) {
		$sql = "UPDATE $this->_buy_password SET num=$num WHERE uid=$uid";
		return $this->exec ( $sql );
	}
	
	/**
	 * 
	 * @return BuyPasswordModel
	 */
	public static function instance() {
		return parent::_instance ( __CLASS__ );
	}
}